#ifndef WF_DRAWIMAGE_H
#define WF_DRAWIMAGE_H

#include "pf_previewactioninterface.h"
#include "pf_image.h"
#include "gui_export.h"

/**
 * This action class can handle user events for inserting bitmaps into the
 * current drawing.
 *
 */
class GUI_EXPORT WF_DrawImage : public PF_PreviewActionInterface {
	Q_OBJECT
public:
    /**
     * Action States.
     */
    enum Status {
		ShowDialog,        /**< Dialog. */
        SetTargetPoint,    /**< Setting the reference point. */
		SetAngle,          /**< Setting angle in the command line. */
		SetFactor          /**< Setting factor in the command line. */
		//SetColumns,        /**< Setting columns in the command line. */
		//SetRows,           /**< Setting rows in the command line. */
		//SetColumnSpacing,  /**< Setting column spacing in the command line. */
		//SetRowSpacing      /**< Setting row spacing in the command line. */
    };

public:
    WF_DrawImage(PF_Container& container,
                        PF_GraphicView& graphicView);
    ~WF_DrawImage();

	static QAction* createGUIAction(LX_Define::ActionType /*type*/, QObject* /*parent*/);
	
	virtual LX_Define::ActionType rtti() {
		return LX_Define::ActionDrawImage;
	}

    virtual void init(int status=0);

	void reset();

    virtual void trigger();

    virtual void mouseMoveEvent(PF_MouseEvent* e);
    virtual void mouseReleaseEvent(PF_MouseEvent* e);

    virtual void coordinateEvent(PF_CoordinateEvent* e);
    virtual void commandEvent(PF_CommandEvent* e);
	virtual PF_StringList getAvailableCommands();

	virtual void showOptions();
	virtual void hideOptions();

    virtual void updateMouseButtonHints();
    virtual void updateMouseCursor();
    virtual void updateToolBar();

	double getAngle() {
		return data.uVector.angle();
	}

	void setAngle(double a) {
		double l = data.uVector.magnitude();
		data.uVector.setPolar(l, a);
		data.vVector.setPolar(l, a+M_PI/2);
	}

	double getFactor() {
		return data.uVector.magnitude();
	}

	void setFactor(double f) {
		double a = data.uVector.angle();
		data.uVector.setPolar(f, a);
		data.vVector.setPolar(f, a+M_PI/2);
	}

protected:
	PF_ImageAttribute data;
        QImage img;
	
	/** Last status before entering option. */
	Status lastStatus;
};

#endif
